#ifndef AUTOLOCK_H
#define AUTOLOCK_H

class Lockable;

#define LOCK	AutoLock auto_lock_macro_variable(this);

/**
 * This class provides automatic locking/unlocking services.
 * It is to be used the following way:
 *
 * void letsDoStuff(Lockable* object) {
 *	AutoLock auto_lock(object);
 *	object->doStuff();
 *	doSomeOtherStuff();
 * }
 *
 * The lock is automatically released when the autolock stops
 * to exist, which, in the above case, is at the end of the function.
 * It can be very useful when you have a function with many exit points.
 */
class AutoLock {
	const Lockable* object;
public:
	AutoLock(const Lockable* object);
	~AutoLock();
};

#endif

